﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace Hong.Pan
{
    public interface IPan
    {
        /// <summary>
        /// 网盘的登录地址
        /// </summary>
        public string LoginUrl { get; }

        /// <summary>
        /// 判断是否登录
        /// </summary>
        /// <returns></returns>
        public bool IsLogin();

        /// <summary>
        /// 登录完成
        /// </summary>
        public bool Logined(string param);

        /// <summary>
        /// 盘的基本信息
        /// </summary>
        /// <returns></returns>
        public Task<JsonNode?> Info();

        /// <summary>
        /// 网盘容量信息
        /// </summary>
        /// <returns></returns>
        public Task<JsonNode?> quota();

        /// <summary>
        /// 读文件或目录
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public Task<List<PanFileInfo>?> Read(string path);

        /// <summary>
        /// 读文件或目录
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public Task<List<PanFileInfo>?> Read(PanFileInfo file);

        /// <summary>
        /// 读文件并下载保存到本地目录
        /// </summary>
        /// <param name="path">服务器路径</param>
        /// <param name="localpath">本地路径</param>
        /// <returns></returns>
        public Task<int> Read(string path, string localpath);

        /// <summary>
        /// 读文件并下载保存到本地目录
        /// </summary>
        /// <param name="file">读的文件</param>
        /// <param name="localpath">本地路径</param>
        /// <returns></returns>
        public Task<int> Read(PanFileInfo file, string localpath, Action<long>? callback = null);

        /// <summary>
        /// 读视频文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public Task<VideoInfo?> ReadVideo(PanFileInfo file);

        /// <summary>
        /// 写文件
        /// </summary>
        /// <param name="path"></param>
        /// <param name="localpath"></param>
        /// <returns></returns>
        public Task<int> Write(string path, string localpath);

        /// <summary>
        /// 写文件
        /// </summary>
        /// <param name="path"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public Task<int> Write(string path, Byte[] data);

        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public Task<int> Delete(string path);
    }
}
